import gugga.application.ApplicationController;
import gugga.application.NavigationManager;
import gugga.application.Section;
import gugga.navigation.MenuNavigation;
import gugga.navigation.NavigationButton;

import useOfSequences.DemonstrationSection;

/**
 * @author bony
 */
class useOfSequences.Application 
 	extends ApplicationController 

{
	// List all the application fields here. 
	private var mMainNavigation:MenuNavigation;
	
	private var mAboutButton:NavigationButton;
	private var mInterruptibleButton:NavigationButton;
	private var mManagingButton:NavigationButton;
	
	private var mDemonstrationSection:DemonstrationSection;
	private var mInterruptibleSection:Section;
	private var mManagingSection:Section;
	
	//constructor	
	public function Application() 
	{
		// The constructor of the super class must be called.
		super();
		
		// The function getComponent creates a mapping between the instances on the scene and
		// the member variables of the Application class.
		mMainNavigation = getComponent("PrimaryNavigation");
		mDemonstrationSection = getComponent("DemonstrationSection");	
		mInterruptibleSection = getComponent("InterruptibleSection");	
		mManagingSection = getComponent("ManagingSection");	
	}
	
	// All Objects instantiated inside the Application inherit UIComponentEx except macromedia components.
	// This function is required because we have to make sure that 
	// all objects inside the Application are associated with their respective classes and are avaialable and ready to work.
	// All sections are phisically nested inside the main Application and their initialization is not immediate.
	// Before execution of that function you cannot call any event related methods or mixin related methods of the objects.
	
	public function initUI()
	{
		// Call the inherited ApplicationController's initUI()
		super.initUI();
		
		// Configure main navigation.
		configureMenu();
		
		// Register all the sections in the application.
		registerSections();
				
		// Open default section.				
		openSection("Demonstration");
		// Set navigation state. Should be set only the first time.
		NavigationManager.Instance.startNavigations();
		NavigationManager.Instance.markNavigations("Demonstration");
		
		// Triger initializing sequence.
		initialize();
			
		// Activating sequence		
		// Using default activating sequence.
		
		// Open sequence		
		// Using default open sequence.
		
		// Close sequence		
		// Using default close sequence.    		
	} 
	public function configureMenu()
	{
		// List all items used for navigation - each one must have it's own unique ID.		
		mMainNavigation.registerChildSubItem("btnDemonstration","Demonstration","Demonstration");
		mMainNavigation.registerChildSubItem("btnInterruptible","Interruptible","Interruptible");
		mMainNavigation.registerChildSubItem("btnManaging","Managing","Managing");
		
		NavigationManager.Instance.registerNavigation(mMainNavigation, "MainNavigation");	
	}
	
	public function registerSections()
	{
		registerChildSection("DemonstrationSection","Demonstration","Demonstration");
		registerChildSection("InterruptibleSection","Interruptible","Interruptible");
		registerChildSection("ManagingSection","Managing","Managing");
				
	}	
}